//
//  MyWorkTableViewCell.m
//  WULIHH
//
//  Created by tang on 16/4/20.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "MyWorkTableViewCell.h"
#import "Header.h"
//#import "UIImageView+AFNetworking.h"
//#import "UIImageView+WebCache.h"

#import "MyWorkDetalTableViewCell.h"

@interface MyWorkTableViewCell ()<UITableViewDataSource, UITableViewDelegate>
{
    UILabel *titleLable;
    UITableView *workTableView;
    NSArray *array;
}

@end


@implementation MyWorkTableViewCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
        [self setBackgroundColor:uicolor(237, 237, 237)];
        
        UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 7.0, WithView, 105)];
        [self addSubview:backView];
        [backView setBackgroundColor:[UIColor whiteColor]];
        
        titleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 13.0, WithView-10.0, 14.0)];
        [titleLable setTextAlignment:NSTextAlignmentLeft];
        [titleLable setFont:[UIFont systemFontOfSize:12.5]];
        [backView addSubview:titleLable];
        
        workTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 60, WithView-20)];
//        [workTableView setBackgroundColor:[UIColor redColor]];
        [workTableView setShowsVerticalScrollIndicator:YES];
        [workTableView setShowsHorizontalScrollIndicator:YES];
        
        [workTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
        [self addSubview:workTableView];
        [workTableView setBackgroundColor:[UIColor clearColor]];
        [workTableView setCenter:CGPointMake((WithView)/2.0, 70)];
        [workTableView setTransform:CGAffineTransformMakeRotation(-M_PI/2.0)];
        [workTableView setDataSource:self];
        [workTableView setDelegate:self];

        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pressPush)];
        [workTableView addGestureRecognizer:tap];
    }
    return self;
}




- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 65.0;
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return array.count;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellInden = @"cell";
    MyWorkDetalTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellInden];
    if (!cell) {
        cell = [[MyWorkDetalTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellInden];
    }
    [cell setTransform:CGAffineTransformMakeRotation(M_PI/2.0)];
    [cell setBackgroundColor:[UIColor clearColor]];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    [cell setImageUrlString:[[array objectAtIndex:indexPath.row] valueForKey:@"imageUrl"]];
    return cell;
}



//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    NSLog(@"%d", self.tag);
//}


- (void)pressPush
{
//    NSLog(@"111111111");
    [_MMyWorkTableViewCellDelegate pushWithTag:(int)self.tag];
}


- (void)setModelWithMyWork:(NSDictionary *)dic
{
//    NSLog(@"%@", dic);
    [titleLable setText:[dic valueForKey:@"title"]];
    array = [dic valueForKey:@"images"];
    [workTableView reloadData];
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
